﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Reticulum
{
    public partial class Select : Form
    {
        public Select()
        {
            InitializeComponent();
        }
        DataSet ds = new DataSet();
        private void Select_Load(object sender, EventArgs e)
        {
            string sql = "select UserName,UserAccount,UserPwd,UserPhone,Sex,BloodGroup,Birthday,Occupational," +
                "Company,Area,Hometown,Email,UploadState,DownloadState from Users";

            DataSet ds = DBHelps.Adapter(sql);

            dataGridView1.AutoGenerateColumns = false;

            dataGridView1.DataSource = ds.Tables[0];
        }
        private void Selectc_Load(object sender, EventArgs e)//刷新
        {
            string sql = "select UserName,UserAccount,UserPwd,UserPhone,Sex,BloodGroup,Birthday,Occupational," +
                "Company,Area,Hometown,Email,UploadState,DownloadState from Users";

            DataSet ds = DBHelps.Adapter(sql);

            dataGridView1.AutoGenerateColumns = false;

            dataGridView1.DataSource = ds.Tables[0];
        }


        private void toolStripButton1_Click(object sender, EventArgs e)//模糊查询
        {
            string sql = "select UserName,UserAccount,UserPwd,UserPhone,Sex,BloodGroup,Birthday,Occupational," +
                "Company,Area,Hometown,Email,UploadState,DownloadState from Users";

            DataSet ds = DBHelps.Adapter(sql);
            //获取输入的关键字
            string UserName=toolStripTextBox1.Text;
            //创建dataview对象
            DataView dv = ds.Tables[0].DefaultView;
            //模糊查询
            dv.RowFilter = string.Format("UserName like '%{0}%'", UserName);
            //设置DataView的数据源
            this.dataGridView1.DataSource = dv;
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            Selectc_Load(sender, e);//刷新加载数据
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
